import VueRouter from "vue-router";
import Vue from "vue";
// 安装
Vue.use(VueRouter)
// 导入组件
const Home = () => import('views/home/Home')
const Category = () => import('views/category/Category')
const Cart = () => import('views/cart/Cart')
const Profile = () => import('views/profile/Profile')
const Detail = () => import('views/detail/Detail')

// 配置路由
const routes = [
  {
    path: '',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    component: Home
  },
  {
    path: '/cart',
    name: 'Cart',
    component: Cart
  },
  {
    path: '/category',
    component: Category
  },
  {
    path: '/profile',
    name: 'Profile',
    component: Profile
  },
  {
    path: '/detail/:iid',
    name: 'Detail',
    component: Detail
  },
]
//在router4中使用createRouter替代了new VueRouter;
const router = new VueRouter({
  routes,
  mode: "history"
  //在此处引入所有页面的路由配置数组routes;
})

// 3.导出
export default router


